package com.itheima.publisher.config;


import jakarta.annotation.PostConstruct;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Configuration;

@Slf4j
@AllArgsConstructor
@Configuration
public class MQConfig {
    public final RabbitTemplate rabbitTemplate;

    @PostConstruct
    public void init(){
        rabbitTemplate.setReturnsCallback(returned -> {
            log.error("触发returb callback,");
            log.debug("exchange:{}", returned.getExchange());
            log.debug("routingKey:{}",returned.getExchange());
            log.debug("messsgae:{}",returned.getMessage());
            log.debug("replyCode:{}",returned.getReplyCode());
            log.debug("replyText:{}",returned.getReplyText());
        });
    }
}
